

params {
    info {
	reference = "https://docs.google.com/document/d/12UCZZGe03Y4yDU6NUNzeID1LBa9VBXd6QKs67uX6onw/edit"
    }

   outdir = "/bulk_rnaseq/nextflow"
   genomesdir = "/bulk_rnaseq/ref_genome"

   genome {
       HTseqGenes = "/bulk_rnaseq/datasets/HTseq_genes.txt"
    }

   samtools {
     memory = 4000000000
    }
   
   star_index = "star_index" 
   
   gtf {
	local {
	    path = "HG38v25"
	    name = "gencode.v25.basic.annotation.gtf"
	}
	remote {
            url = "ftp://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/release_25/gencode.v25.basic.annotation.gtf.gz"
            format = "gzip"
	}
    }
    fasta {
	local {
	    path = "HG38v25"
	    name = "GRCh38.primary_assembly.genome.fa"
	}
	remote {
            url = "ftp://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/release_25/GRCh38.primary_assembly.genome.fa.gz"
	    format = "gzip"
	}
    }
    intron_bed {
	local {
	    path = "annotation"
	    name = "intron_annotation_human_gencodev25.bed"
	}
	remote {
	    url = "http://www.genemine.org/introns/intron_annotation_human_gencodev25.bed"
	    format = "text"
	}
    }

    // adapters is an internal reference to the container
    adapters = "/opt/bbmap/resources/adapters.fa"

    rRNA {
	local {
	    path = "annotation" 
	    name = "hg38_rRNA.bed"
        }
	remote {
	    url = "https://sourceforge.net/projects/rseqc/files/BED/Human_Homo_sapiens/hg38_rRNA.bed.gz/download"
	    format = "gzip"
	}	
    }
    mtRNA {
	local {
	    path = "annotation" 
	    name = "mtrna.bed"
	}
	remote {
	    url= "https://genome.ucsc.edu/cgi-bin/hgTables?hgsid=688253795_bBHSP8amBAaB2svN68EAZmlkGdQC&boolshad.hgta_printCustomTrackHeaders=0&hgta_ctName=tb_knownGene&hgta_ctDesc=table+browser+query+on+knownGene&hgta_ctVis=pack&hgta_ctUrl=&fbQual=whole&fbUpBases=200&fbExonBases=0&fbIntronBases=0&fbDownBases=200&hgta_doGetBed=get+BED" // this link must be verified
	    format = "text"
	}
	note = "This table cames from UCSC, transcripts id are not used so there is no need to perform a conversion with ENSG/ENST"
    }
}

// Set params profile
singularity.autoMounts = true
singularity.enabled = true
singularity.cacheDir ='/hpcapps/opt/'

profiles {
  standard {
     process{
        container = '/hpcapps-archive/opt/organoids-rna-seq.0.1.simg'
        executor = 'sge'
        penv = 'make'
        queue = 'batch.q'
        }
    }
}

def timestamp() {
    def now = new Date()
    now.format("yyyyMMdd_HHmm", TimeZone.getTimeZone('UTC'))
}

timeline {
  enabled = true
  file = "rnaseq_timeline_${timestamp()}.html"
}

trace {
  enabled = true
  file = "rnaseq_trace_${timestamp()}.txt"
}

report {
  enabled = true
  file = "rnaseq_report_${timestamp()}.html"
  }

// Capture exit codes from upstream processes when piping
process.shell = ['/bin/bash', '-euo', 'pipefail']

// Function to ensure that resource requirements don't go beyond
// a maximum limit
def check_max(obj, type) {
  if(type == 'memory'){
    if(obj.compareTo(params.max_memory) == 1)
      return params.max_memory
    else
      return obj
  } else if(type == 'time'){
    if(obj.compareTo(params.max_time) == 1)
      return params.max_time
  }
}
